package com.xpgk.mvc.ddc.query.businessQuery;

import java.util.List;

import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.ddc.entity.Business;
import com.xpgk.mvc.ddc.entity.Owner;
import com.xpgk.mvc.ddc.entity.Plate;
import com.xpgk.mvc.ddc.entity.Vehicle;
import com.xpgk.mvc.ddc.entity.VehicleParemeters;
import com.xpgk.mvc.organization.Organization;

public class BusinessQueryController extends BaseController{

	public void index(){
		Organization org = Organization.dao.findById(getCUserOrganIds());
		setAttr("curOrgan", org);
		render("businessQuery.html");
	}
	public void getList(){
		String json = paging(splitPage, BusinessQuerySQL.sqlId_splitPageSelect, BusinessQuerySQL.sqlId_splitPageFrom);
		renderJson(json);
	}
	/*public void toDetail(){
		setAttr("ids", getPara("ids"));
		render("businessDetail.html");
	}*/
	public  void  toDetail(){
		ids=getPara("ids");
		Business business = Business.dao.findById(ids);
		String type = business.getStr(Business.column_TYPE);
		//转移
		setAttr("owner2", Owner.dao.findById(business.get("OLDOWNERIDS")));
		setAttr("vehicle", Vehicle.dao.findById(business.get("VEHICLEIDS")));
		//变更
		setAttr("vehicleparemeters2", VehicleParemeters.dao.findById(business.get("OLDPAREMETERSIDS")));
		//通用
		setAttr("owner", Owner.dao.findById(business.get("NEWOWNERIDS")));
		setAttr("vehicleparemeters", VehicleParemeters.dao.findById(business.get("NEWPAREMETERSIDS")));
		setAttr("plate", Plate.dao.findById(business.get("NEWPLATEIDS")));
		setAttr("business", business);
		if(type!=null){
			switch(type){
			case "1":
				render("zcDetails.html");break;
			case "2":
				render("zyDetails.html");break;
			case "3":
				render("bgDetails.html");break;
			case "4":
				render("zxDetails.html");break;
			case "5":
				render("hpDetails.html");break;
			case "6":
				render("zjDetails.html");break;
		 	default:
	            System.out.println("default");break;
	        }
			
		}
		
	}
	public void busDetail(){
		String ids =  getPara("ids");
		List<Business> b = Business.dao.find("select * from DDC_BUSINESS where IDS = ?",ids);
		renderJson(b);
	}
}
 